package com.ck.ips.model.vo;

import com.ck.core.util.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.ParseException;
import java.util.Arrays;
import java.util.List;

/**
 * @description: 播放日志
 * @author: zhanglei
 * @date: 2019/5/14 9:27
 */
public class PlayLogVO {
    private Logger logger = LoggerFactory.getLogger(PlayLogVO.class);
    /**
     * 终端组名
     */
    private String groupName;

    /**
     * 终端唯一编码
     */
    private String deviceCode;

    /**
     * 终端mac
     */
    private String deviceMac;

    /**
     * 终端序列号
     */
    private String deviceSerialNum;

    /**
     * 统计周期
     */
    private String playDate;

    /**
     * 素材名称
     */
    private String fileName;

    /**
     * 素材播放次数
     */
    private Integer playNum;

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public String getDeviceCode() {
        return deviceCode;
    }

    public void setDeviceCode(String deviceCode) {
        this.deviceCode = deviceCode;
    }

    public String getDeviceMac() {
        return deviceMac;
    }

    public void setDeviceMac(String deviceMac) {
        this.deviceMac = deviceMac;
    }

    public String getPlayDate() {
        StringBuilder playDateStr = new StringBuilder();
        List<String> dateList = Arrays.asList(this.playDate.split("-"));
        int i = 0;
        for(String date : dateList){
            try {
                if(i!=0){
                    playDateStr.append("-");
                }
                String dateString = "";
                if(date.length()!=6){
                    Long dateLong = DateUtils.stringTimeToLongTimeStamp(date,DateUtils.PATTEN_YYYYMMDD);
                    dateString = DateUtils.longTimeStampToStringDate(dateLong,DateUtils.PATTEN_YMD_DEL);
                }else{
                    Long dateLong = DateUtils.stringTimeToLongTimeStamp(date,DateUtils.PATTEN_YYYYMM);
                    dateString = DateUtils.longTimeStampToStringDate(dateLong,DateUtils.PATTEN_YM_DEL);
                }
                playDateStr.append(dateString);
            } catch (ParseException e) {
                logger.error("处理播放日志日期错误：" + e.getMessage(), e);
            }
            i++;
        }
        return playDateStr.toString();
    }

    public void setPlayDate(String playDate) {
        this.playDate = playDate;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public Integer getPlayNum() {
        return playNum;
    }

    public void setPlayNum(Integer playNum) {
        this.playNum = playNum;
    }

    public String getDeviceSerialNum() {
        return deviceSerialNum;
    }

    public void setDeviceSerialNum(String deviceSerialNum) {
        this.deviceSerialNum = deviceSerialNum;
    }

}
